Hashim Amla's 20th Test century kept South Africa afloat on the opening day of the series against Pakistan in Abu Dhabi.