Optimal rectification in the ultrastrong coupling regime