Vae, puto deus fio. How to make a Bad Emperor

How did the images and possible deification of recently deceased Roman emperors come into being? How were they forgotten?