change StringIO into BytesIO for Python 3