JSONSerializer compatibility for Python 3 bytes