Fix regressions in support for bytes / unicode

Fix regressions in support for bytes / unicode in certain APIs #15.
Added a check for _text_type, raise a DeprecationWarning and encode the
str to utf-8. This should preserve 0.13 API calls.
I used the 0.13 test suite with the 0.14 code and made the necessary
changes to make 0.13 and 0.14 tests pass.
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index 2731d64..ff0259a 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -310,6 +310,12 @@
         :param capath: In which directory we can find the certificates
         :return: None
         """
+
+        # Backward compatibility
+        if isinstance(cafile, _text_type):
+            DeprecationWarning("str object in cafile is no longer accepted, use bytes")
+            cafile = cafile.encode('utf-8')
+
         if cafile is None:
             cafile = _ffi.NULL
         elif not isinstance(cafile, bytes):
@@ -970,6 +976,12 @@
                       API, the value is ignored
         :return: The number of bytes written
         """
+
+        # Backward compatibility
+        if isinstance(buf, _text_type):
+            DeprecationWarning("str object in buf is no longer accepted, use bytes")
+            buf = buf.encode('utf-8')
+
         if isinstance(buf, _memoryview):
             buf = buf.tobytes()
         if isinstance(buf, _buffer):
@@ -994,6 +1006,12 @@
                       API, the value is ignored
         :return: The number of bytes written
         """
+
+        # Backward compatibility
+        if isinstance(buf, _text_type):
+            DeprecationWarning("str object in buf is no longer accepted, use bytes")
+            buf = buf.encode('utf-8')
+
         if isinstance(buf, _memoryview):
             buf = buf.tobytes()
         if isinstance(buf, _buffer):
@@ -1079,6 +1097,12 @@
         :param buf: The string to put into the memory BIO.
         :return: The number of bytes written
         """
+
+        # Backward compatibility
+        if isinstance(buf, _text_type):
+            DeprecationWarning("str object in buf is no longer accepted, use bytes")
+            buf = buf.encode("ascii")
+
         if self._into_ssl is None:
             raise TypeError("Connection sock was not None")
 
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index 8d971f2..0aa140a 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -1952,6 +1952,12 @@
 
         :return: The string containing the PKCS12
         """
+
+        # Backward compatibility
+        if isinstance(passphrase, _text_type):
+            DeprecationWarning("str object in passphrase is no longer accepted, use bytes")
+            passphrase = passphrase.encode('utf-8')
+
         if self._cacerts is None:
             cacerts = _ffi.NULL
         else:
@@ -2249,6 +2255,12 @@
     :param digest: message digest to use
     :return: signature
     """
+
+    # Backward compatibility
+    if isinstance(data, _text_type):
+        DeprecationWarning("str object in passphrase is no longer accepted, use bytes")
+        data = data.encode('utf-8')
+
     digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
     if digest_obj == _ffi.NULL:
         raise ValueError("No such digest method")
@@ -2283,6 +2295,12 @@
     :param digest: message digest to use
     :return: None if the signature is correct, raise exception otherwise
     """
+
+    # Backward compatibility
+    if isinstance(data, _text_type):
+        DeprecationWarning("str object in passphrase is no longer accepted, use bytes")
+        data = data.encode('utf-8')
+
     digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
     if digest_obj == _ffi.NULL:
         raise ValueError("No such digest method")
@@ -2374,6 +2392,12 @@
     :param passphrase: (Optional) The password to decrypt the PKCS12 lump
     :returns: The PKCS12 object
     """
+
+    # Backward compatibility
+    if isinstance(passphrase, _text_type):
+        DeprecationWarning("str object in passphrase is no longer accepted, use bytes")
+        passphrase = passphrase.encode('utf-8')
+
     if isinstance(buffer, _text_type):
         buffer = buffer.encode("ascii")