Fixed TypeError when serializing 'bytes' in Python 3