Theory of the photovoltage at semiconductor surfaces and its application to diffusion length measurements