When you sell a long-term asset like gold, you have to pay capital gains tax on earnings. But there’s a way to save on this tax legally