Implementation of Huffman encoder