Add support for garbage collecting images.

Closes #157