implemented Huffman.codeBits
simpler encode