Gold ends lower, but books best weekly gain since July