Image optimization backport

a-la VIP