Linear and nonlinear optical response of LiNbO3 calculated from first principles