Changed StringIO to BytesIO for python 3