Fix correct extension when using image with vars

This should fix #552 : Extension dropped when using vars with image twig tag