Tesla has reported a surprise profit for the third quarter, fulfilling CEO Elon Musk's promise the company would start booking profits in the second half of 2018.