Huffman tree generation, encoding, decoding