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