We develop a fast numerical procedure for the analysis of nonlinear and nonlocal electrodynamics of type-II superconducting films in transverse magnetic fields coupled with heat diffusion. Using this procedure, we explore the stability of such films with respect to dendritic flux avalanches. The calculated flux patterns are very close to experimental magneto-optical images of MgB2 and other superconductors, where the avalanche sizes and their morphology change dramatically with temperature. Moreover, we find the values of a threshold magnetic field, which agrees with both experiments and linear stability analysis. The simulations predict the temperature rise during an avalanche, where for a short time T≈1.5Tc, and a precursor stage with large thermal fluctuations.