Greig Laidlaw scored 26 of Scotland's 36 points as his side held off Samoa to confirm their place in the quarter-finals.