Technique for photoshop as follows - other programs vary in name but should be similar in nature
Best to add some space to the image by increasing the image size by say 10%
go to Edit > Transform > Perspective
Use the corner 'handles' to make the desired correction and press 'Enter' when OK.
The 'error' may not have been uniform, and additional correction may be necessary, use 'Distort' or 'Skew' from the Transform menu.
Cropping of the image will be necassary to trim the 'trapezium shape
Don't over correct. Leave a little bit of convergence for a sense of perspective. A dead vertical building, especially if viewed from a low viewpoint, tends to look very unnatural.
Quick Example - taken at Wells cathedral
Not best picture but gives the idea, notice how this procedure also crops around the picture as a result of doing this - hope it helps