Use io.BytesIO instead of StringIO