Fix correct extension when using image with vars