BYD outpaced Tesla in the second quarter as the Chinese carmaker posted record sales of hybrid and electric vehicles.