An alternative method to simulate heat transport in the multiphase lattice Boltzmann (LB) method is proposed. To solve the energy transport equation when phase boundaries are present, the method of a passive scalar is considerably modified. The internal energy is represented by an additional set of distribution functions, which evolve according to an LB-like equation simulating the transport of a passive scalar. Parasitic heat diffusion near boundaries with a large density gradient is suppressed by using special "pseudoforces" which prevent the spreading of energy. The compression work and heat diffusion are calculated by finite differences. A new method to take into account the latent heat of a phase transition Q(T) is realized. The latent heat is released or absorbed continuously inside a thin transition layer in a certain range of density, ρ1<ρ<ρ2. This allows one to avoid interface tracking. Several tests were carried out concerning all aspects of the processes. It is shown that the Galilean invariance and the scaling of the thermal conduction process hold, as well as the correct dependence of the sound speed on the heat capacity ratio. The method proposed has low scheme diffusion of the internal energy, and it can be applied to modeling a wide range of multiphase flows with heat and mass transfer even for high density ratios of liquid and vapor phases.