On the Generalization Properties of Diffusion Models