support Python 3 and BytesIO