Although the aerospace company lost money in the second quarter, it built and sold more planes as it recovered from quality crises and a workers strike.