backporting image optimizations

See: https://github.com/GigaOM/gigaom/issues/5525
Merge pull request #17 from zbtirrell/backport-image-optimizations

backporting image optimizations