'Return a tar header as a string of 512 byte blocks.'

def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors='surrogateescape'):

    info = self.get_info()
    if (format == USTAR_FORMAT):
        return self.create_ustar_header(info, encoding, errors)
    elif (format == GNU_FORMAT):
        return self.create_gnu_header(info, encoding, errors)
    elif (format == PAX_FORMAT):
        return self.create_pax_header(info, encoding)
    else:
        raise ValueError('invalid    format')
