Fluxon dynamics in long Josephson junctions in the presence of a temperature gradient or spatial nonuniformity