Add Python 3 compatibility layer, although the token still fails when being JSON encoded.