Quantum size effects in Pb films from first principles: The role of the substrate