Twitter, which this week agreed to be bought by billionaire Elon Musk, has said its user numbers grew faster than expected over the past year.