Magnetotransport in inhomogeneous magnetic fields