We have studied the underdamped dynamics of vortices in a long Josephson junction in the presence of a temperature gradient along the junction. The flux-flow voltage was found to depend on the mutual orientation of the temperature gradient and the external magnetic field. This effect is caused by the difference in viscosity coefficient on the hot and the cold junction sides. The motion of Josephson vortices is simulated using the perturbed sine-Gordon model with the spatially dependent loss term. Simulation results are in good agreement with experimental data.