basic message encoding/decoding in place