Elon Musk said Tuesday that the past couple of months have been "excruciating" and "hellish" for him.

But he maintained that Tesla can meet production goals for its first mass-market car, the Model 3. Musk also said the company won't run out of cash any time soon.

Tesla's company's stock rose about 1% after hours. It's down about 16% from a year ago.

"We've made a lot of mistakes with Model 3 production. But we recognize those mistakes and we're confident we know how to address them," Musk said at Tesla's annual shareholder meeting. "And in fact, we are addressing them."

The CEO, onstage in Mountain View, California Tuesday afternoon, said it is "quite likely" that Tesla will hit its goal of building 5,000 Model 3 sedans per week by the end of the month, and can currently churn out 3,500 Model 3s per week.

The company has struggled to shift from putting out small numbers of luxury vehicles to making cars on a much larger scale. This has caused some investors to worry about the company's cash flow.

Related: Tesla's Model 3 finally nabs Consumer Reports recommendation

In April, Tesla announced that it's producing about 2,000 Model 3 cars per week. Bloomberg, which has been tracking production of the Model 3 by keeping track of vehicle identification numbers issued to Tesla, estimates that production is currently around 2,500 cars a week.

Musk said Tuesday that the company expects to have "positive cash flow" in last two quarters of its fiscal year.

"We do not expect to need to raise any incremental debt or equity," he said.

Musk and executive Robin Ren also teased an upcoming announcement about a Tesla factory in Shanghai. The plant would be the first Tesla Gigafactory outside the United States.

Musk has recently had a tough run, spurring questions about whether he has the temperament to continue leading Tesla.

In the past weeks, Musk insulted analysts during an earnings call and told them that "boring, bonehead questions are not cool." The company's stock subsequently fell, even though the automaker had posted better-than-expected earnings results.

Musk later admitted he was "foolish" to respond the way he did.

But shareholders appeared Tuesday to affirm Musk's leadership, shooting down a proposal that could have stripped him of his role as chairman of the board.

They also approved the company's decision to reappoint three directors: James Murdoch, the CEO of 21st Century Fox (FOX); Kimbal Musk, an entrepreneur and Elon's brother; and Antonio Gracias, head of Valor Management and an early investor in Tesla.

An activist shareholder firm, CtW Investment Group, had been leading an effort to jettison of all three. The group argued that the Tesla board acts as a rubber stamp on Musk, and the board needed directors with greater independence.

-- CNNMoney's Chris Isidore contributed to this report.