Fix bug in huffman encoder