Encode/Decode seems to be working with minimal testing, something wrong I/O, output file is always empty. Needs extensive testing