Setup encode/decode methods.