Update encoding.py

Open and update messages are now valid JSON messages.
Update messages contains now the 'type' element.