Iterative solutions for electromagnetic scattering by gratings