removed panic and log.Fatalln code on error and added a return value err to Decode and Encode functions.