Gold ends higher, books best weekly gain in seven months