New Zealand legalizes same-sex marriage