import struct


def serialize_hdu(hdu):
    """
    Serialize a fits object.

    args:
        hdu (astropy.io.fits.HDUList): a fits object
    returns:
        str: a serialized fits object.
    """
    data = struct.pack('=%sf' % hdu.data.size, *hdu.data.flatten('F'))
    header = hdu.header.tostring()
    return data, header