Fixed issue when painting corrupted images