Added encode functions. Missing check sum calc for end of chunk