Bugfixes: make sure not to replace the image twice, try harder at
finding out dimensions of an invisible image