gold extends gains, but heads for third week of losses