Fast Huffman encoding