Scattering of fast flare electrons in solar atmosphere and their X-ray spectrum