Gold ends at 3-week low as U.S. stock indexes tap record highs