fix data type for json.loads() in python 3.x

json.loads(data) will raise TypeError: the JSON object must be str, not
'bytes' in Python 3.x unless we decode data first.