Update encoding.py

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