The second-order optical potential for pion-nucleus scattering