Boeing's (BA -2.20%) 787 Dreamliner widebody has had a huge impact on commercial aviation since the first one was delivered back in 2011. The Dreamliner has made dozens of new nonstop routes possible with a unique combination of long range and low trip costs.

However, the 787 Dreamliner program hasn't been a financial success for Boeing thus far. The company accumulated almost $30 billion of losses from building the first 500 Dreamliners. That doesn't even count the massive cost of developing this new aircraft family -- estimated at around $15 billion.

Fortunately, Boeing has been building 787s at a profit since 2016. Over the next few years, the profitability of Dreamliner production will rise even further, allowing Boeing to offset the losses incurred in previous years.

Solid trends already

Under the rules of program accounting, Boeing has been booking a small profit on each quarter's 787 production, based on the program's expected average profitability over the long run. The cumulative difference between these book "profits" and the cash losses that Boeing actually incurred up until two years ago were reported as deferred production costs.

A Boeing 787-9 flying over a river

Dreamliner production turned cash positive for the first time in 2016. Image source: Boeing.

Dreamliner production is now consistently cash positive, but Boeing still reports its deferred production costs each quarter. Now this metric indicates how fast Boeing is generating cash profits from the 787 program to offset the earlier cash losses.

Deferred production costs have declined by more than $500 million in each of the last two reported quarters. That's already a big improvement relative to early 2016, when the program still hadn't quite reached the breakeven point. However, there is plenty of room for additional improvement.

The production mix is getting better

One fundamental reason for the Dreamliner program's rising profitability is that the production mix is steadily shifting toward higher-margin models. Because of design mistakes, the 787-8 -- the first model to enter production -- costs nearly as much to build as the larger 787-9 variant. As a result, production of the 787-8 is barely profitable even today.

By contrast, the 787-9 is very popular and already quite profitable for Boeing. Furthermore, the 787-10, the largest Dreamliner variant, was designed with 90% commonality to the 787-9. This design choice will keep production costs down, allowing Boeing to earn an even higher margin on that model.

A rendering of a Boeing 787-10 in flight

The 787-10 is likely to be Boeing's most profitable Dreamliner model. Image source: Boeing.

Deliveries of the 787-9 first surpassed 787-8 deliveries in 2016, helping to turn the program profitable during that year. In 2017, the production mix shifted even further toward the 787-9, with 110 787-9 deliveries, compared to just 26 for the 787-8.

The production mix will improve further in the next few years. The 787-8 now represents just 10% of the total 787 order backlog -- and dozens of those orders are likely to be canceled or converted to larger models. In 2018, Boeing is on track to deliver just 10 787-8s, according to Dreamliner production expert Uresh Sheth. Meanwhile, deliveries of the 787-10, which is likely to be the most profitable model for Boeing, will start this year.

Lower costs and higher revenue

Two other factors aside from the improving production mix will drive quarterly Dreamliner profits higher. First, unit costs will decline over time. Some of this decline comes from Boeing's internal productivity efforts. However, most of the benefit stems from agreements with its suppliers that call for component costs to decrease as Boeing passes certain production milestones.

Second, in 2019, Boeing will increase the Dreamliner production rate to 14 per month, from the current pace of 12 per month. All else equal, this 17% increase in output would boost the program's quarterly profit by 17%. In addition, a higher production rate will push costs down by allowing Boeing to spread its fixed costs over more units. Thus, the actual increase in quarterly profit from faster production is likely to be even greater.

Boeing's strong cash flow trajectory is a big reason the stock has more than doubled over the past year. For Boeing stock to hold on to its lofty gains, the company will need to capitalize on its opportunity to dramatically improve the 787 program's cash profits in the next few years.