gold ends higher, but posts weekly decline