  An equation is derived to calculate the dynamics of relativistic magnetized
plasma which decelerates by sweeping up matter from the ISM. Reduction to the
non-radiative and radiative regimes is demonstrated. The evolving electron
momentum distribution function in the comoving fluid frame is used to calculate
the observed synchrotron radiation spectrum, assuming that a fixed fraction of
the comoving proton power is instantaneously transformed into a power-law,
"shock"-like electron distribution function. This permits an analytic solution
for the case of a relativistic plasmoid with a constant internal magnetic
field. Breaks in the temporal behavior of the primary burst emission and long
wavelength afterglows occur on two time scales for external ISM density
distributions. The first represents the time when the outflow sweeps up
approximately M/G_0 of material from the ISM, where M is the mass in the
outflow ejecta and G_0 is the initial Lorentz factor of the plasmoid. The
second represents the time when synchrotron cooling begins strongly to regulate
the number of nonthemal electrons that are producing radiation which is
observed at a given energy.
  Results are applied to GRB and blazar variability. The slopes of the time
profiles of the X-ray and optical light cuves of the afterglows of GRB 970228
and GRB 970508 are explained by injection of hard electron spectra with indices
$s < 2$ in a deceleration regime near the radiative limit. We also propose that
blazar flares are due to the transformation of the directed kinetic energy of
the plasmoid when interacting with the external medium, as would occur if
relativistic outflows pass through clouds orbiting the central supermassive
black hole.
