Revert "StringIO patch"

This reverts commit 62f94b534289b7ab0bda879962bf6efb124a9930.
Replaced mktemp with mkstemp
Replaced StringIO with BytesIO