This is a python encoder/decoder