49ers hold off Cowboys