Relativistic and spectator effects in leptogenesis with heavy sterile neutrinos