Implemented error packet encoding and decoding