Use io.BytesIO instead of StringIO.StringIO for cross-version compatibility