Apple's earnings topped analyst expectations, as it continued to sell more iPhones than expected.