use BytesIO instead of StringIO for file data