Plans to legalise assisted dying in Scotland have passed the first stage after MSPs voted in favour of the bill.