South Africa take first innings lead over Pakistan