Positronium formation in positron scattering from hydrogen and helium atoms: the distorted-wave approximation