As other people have mentioned, you can do this in GIMPGIMP and googling helps :P. But suppose that you are not sure which terms to google, here are the steps:
1- Change X color to Y color foreground
Place cursor over the image, right-click > Select > By Color. Click on an area with color X (in this case blue). All blue color will be selected. Then right-click > Edit > Fill with FG Color (where BG Color will have been set to color Y). Done; all X color is now changed to Y color.
2- Change Z color to transparent background
First, make sure that there is an alpha channel in the layer by selecting Layer > Transparency > Add Alpha Channel (if the option is greyed out then there is already an alpha channel, no further action needed). Then place the cursor over the image, right-click > Select > By Color. Click on an area with color Y (in this case white). All white color will be selected. Then right-click > Edit > Cut. Done; all Z color is now transparent.