implement encodeFile and decodeFile methods