invert key image convert and cleaning