Fix incorrect image position when optimizations used