Perturbative QCD calculation of real and virtual Compton scattering