binary mode is actually important
diff --git a/test/test_crypto.py b/test/test_crypto.py
index 6941719..5acf01d 100644
--- a/test/test_crypto.py
+++ b/test/test_crypto.py
@@ -1297,7 +1297,7 @@
         args = '"' + '" "'.join(args) + '"'
     else:
         args = "'" + "' '".join(args) + "'"
-    write, read = popen2("openssl " + args)
+    write, read = popen2("openssl " + args, "b")
     write.write(pem)
     write.close()
     return read.read()