How does an altimeter deal with the non-linear pressure gradient? Altimeters work via an aneroid barometer to sense the atmospheric pressure. If I climb from 2000ft to 4000ft, the altimeter senses that the pressure has reduced by, let's say, 70hpa, and is calibrated to know that 70hpa = 2000ft. 

But the pressure gradient (or rate of change of pressure) reduces with altitude. A climb from FL240 to FL260 might result in a pressure reduction of only 30hpa. Yet it still knows that the aircraft climbed 2000ft. How does the altimeter do this?
It uses a model called The International Standard Atmosphere (ISA) - so may be inaccurate if you don't have one of those to fly through :-)