Blue Cross Blue Shield of Massachusetts said pharmacy spending and Obamacare costs have them bleeding red ink, with the insurer reporting an operating loss of $40.4 million for the three quarters ending in September.

The loss is an improvement from the $103.1 million operating loss the state’s largest insurer reported the same period last year, but reflects ongoing challenges in the insurance market.

“Our modest operating margin this quarter reflects our commitment to keeping premiums affordable…