The cooling of a lava flow, both in the transient and the steady state, is investigated considering that lava rheology is pseudoplastic and dependent on temperature. Lava exits from the vent with constant velocity and flows down a slope under the effect of gravity force inside a channel of rectangular cross section. We consider that cooling of lava is caused by thermal radiation into the atmosphere and thermal conduction at the channel walls and at the ground. The heat equation is solved numerically in a 3-D computational domain, and the solution is tested to evaluate the numerical errors. We study the steady state and the initial transient period of lava cooling. Results indicate that the advective heat transport significantly modifies the cooling rate of lava, slowing down the cooling process. Since the lava velocity depends on temperature, the cooling rate depends on the effusion temperature. Velocity profiles are modified during cooling showing two marginal static zones where the crust can form and remain stable. The fraction of crust coverage is calculated under the assumption that the solid lava is a plastic body with temperature-dependent yield strength. We numerically confirm that heat advection cannot be neglected in the mechanism of formation of lava tubes.