Encode and decode using Huffman trees.