Python 3 compatibility for json serializer