Post-Newtonian evolution of massive black hole triplets in galactic nuclei - I. Numerical implementation and tests