Portugal survive scare against Iran to make knockouts