Fix huffman table writing and implement JFIF header writing.