Beating analyst estimates, the company grew revenue, cut costs, and reported a profit during its second quarter.