Make sure BytesIO receives bytes in Python 3