Amla, Bavuma bat South Africa to safety