England captain Joe Root made a composed half-century as the visitors took control of the third Test against South Africa at Newlands.