add image reference counting for loading/unloading