A reformist who has vowed ease headscarf laws and reach out to the West has been elected as Iran's new president.