Inverting image is working properly