Use io.BytesIO instead of io.StringIO