Update encoding.py

'Type' of message now moved to the top in the JSON message.