Thousands of gay men to be pardoned