Radiation transport in dense interstellar dust clouds. I. Grain temperature