The straightforward way to get AAdvantage miles when shopping at Costo -- without having to pay ahead on a gift card -- is to get a Starwood American Express card.
There's usually a good bonus for signing up, and you can use it many other places besides Costco. You get one Starwood Preferred Guest (SPG) point for each dollar you charge. 20,000 SPG points = 25,000 AAdvantage points -- that's a 25% bonus each time you convert.
You may find that you don't need an AAdvantage Mastercard (with its higher annual fee) any more.