X-ray and γ-ray emissions observed in lightning and long sparks are usually connected with the bremsstrahlung of high-energy runaway electrons. Here, an alternative physical mechanism for producing X-ray and gamma-ray emissions caused by the polarization current and associated electromagnetic field moving with relativistic velocity along a curved discharge channel has been proposed. The existence of fast electromagnetic surface waves propagating along the lightning discharge channel at a speed close to the speed of light in vacuum is shown. The possibility of the production of microwave, X-ray and gamma-ray emissions by a polarization current pulse moving along a curved path via synchrotron radiation mechanism is pointed out. The existence of long tails in the power spectrum is shown, which explains observations of photon energies in the range of 10-100 MeV in the TGF, as well as measured power spectrum of laboratory spark discharge.