Fixes for Py2.7

Nice job on the API! Saves me a lot of work.
Couldn't get it to work though, on vanilla Python 2.7. Made these changes:
Use BytesIO instead of StringIO and encoding 'utf-8' instead of 'unicode'