Fixing a bug in image rendering over ajax