Implemented decoding. During encoding, the tree is written to file with pickle