American Airlines says it has reached an agreement with its pilots’ union to avoid canceling thousands of flights over the last two weeks of the year.