Implement encode & codeBits