Computation of transient electromagnetic waves in inhomogeneous media