Huffman encoding and decoding