Adding image cache.

Previously the code had to be structured to avoid calling
load_image too often (e.g. the images had to be kept in
static members). This allows costumes to be loaded in normal
constructors thus simplifying the code.