New method for determining the nonlinear optical coefficients of thin films