fix module init return values and type initializers and unicode/bytes conversions
diff --git a/OpenSSL/ssl/connection.c b/OpenSSL/ssl/connection.c
index 9c981c6..0289876 100755
--- a/OpenSSL/ssl/connection.c
+++ b/OpenSSL/ssl/connection.c
@@ -1349,7 +1349,7 @@
 }
 
 PyTypeObject ssl_Connection_Type = {
-    PyVarObject_HEAD_INIT(&PyType_Type, 0)
+    PyOpenSSL_HEAD_INIT(&PyType_Type, 0)
     "OpenSSL.SSL.Connection",
     sizeof(ssl_ConnectionObj),
     0,
diff --git a/OpenSSL/ssl/context.c b/OpenSSL/ssl/context.c
index 902d1e4..a30b51f 100644
--- a/OpenSSL/ssl/context.c
+++ b/OpenSSL/ssl/context.c
@@ -368,8 +368,16 @@
         Py_DECREF(type);
         return NULL;
     }
+
+#ifdef PY3
+    {
+        PyObject* asciiname = PyUnicode_AsASCIIString(name_attr);
+        Py_DECREF(name_attr);
+        name_attr = asciiname;
+    }
+#endif
     right_name = (PyUnicode_CheckExact(name_attr) &&
-                  strcmp(name, _PyUnicode_AsString(name_attr)) == 0);
+                  strcmp(name, PyBytes_AsString(name_attr)) == 0);
     Py_DECREF(name_attr);
     res = (PyTypeObject *)type;
     if (!right_name || res->tp_basicsize != objsize) {
@@ -1243,7 +1251,7 @@
 
 
 PyTypeObject ssl_Context_Type = {
-    PyVarObject_HEAD_INIT(&PyType_Type, 0)
+    PyOpenSSL_HEAD_INIT(&PyType_Type, 0)
     "OpenSSL.SSL.Context",
     sizeof(ssl_ContextObj),
     0,
diff --git a/OpenSSL/ssl/ssl.c b/OpenSSL/ssl/ssl.c
index 00b9617..8ac4420 100644
--- a/OpenSSL/ssl/ssl.c
+++ b/OpenSSL/ssl/ssl.c
@@ -84,7 +84,7 @@
     module = Py_InitModule3("SSL", ssl_methods, ssl_doc);
 #endif
     if (module == NULL) {
-        return NULL;
+        PyOpenSSL_MODRETURN(NULL);
     }
 
 #ifndef PY3
@@ -196,14 +196,9 @@
     _pyOpenSSL_tstate_key = PyThread_create_key();
 #endif
 
-#ifdef PY3
-    return module;
-#endif
+    PyOpenSSL_MODRETURN(module);
 
 error:
-#ifdef PY3
-    return NULL;
-#else
+    PyOpenSSL_MODRETURN(NULL);
     ;
-#endif
 }