Add support for garbage collecting images.
Merge pull request #3097 from brendandburns/img

Add support for garbage collecting images.