Palmeiras to buy Milan's Gomez