This didn't initially look right to me because the loop is written in a confusing way. We should always change x in the inner loop. I think it's probably correct but I'd like to see it cleaned up a bit more.
Since we don't actually care about the x and y coordinates, I would suggest a single loop over `width * height` pixels.