Fix image destroy function