Members of the Scottish Parliament have voted in favour of same-sex marriage, in the first step towards its recognition in Scotland.