Tesla posts record quarterly earnings