Implemented the PEP 3333 encoding/decoding dance