Remove unnecessary ''.join...()'s
Inherit from object
Use collections.Counter
Replace to_decimal with int(val, 2).
Close files
Write result piece by piece
Write result piece by piece in huffman encoding