Pakistan's Babar Azam narrowly missed out on a century against New Zealand in the Hamilton Test which the Kiwis won.