change StringIO to BytesIO