Generation of neutron star magnetic fields by thermomagnetic effects