'Save the next segment to the image file, return next checksum value if provided'

def save_segment(self, f, segment, checksum=None):

    f.write(struct.pack('<II', segment.addr, len(segment.data)))
    f.write(segment.data)
    if (checksum is not None):
        return ESPLoader.checksum(segment.data, checksum)
