Put the code to convert the image to grayscale in the try block.