gold ends at a three-week high as the dollar ebbs