Cosmology with massive neutrinos III: the halo mass function and an application to galaxy clusters