England captain Alastair Cook was in fine form as he guided his side to a 10-run win over New Zealand.