Gold ends higher as U.S. dollar index falls to a nearly 3-week low