A man has been jailed for 17 years for historic sexual offences committed over a 20-year period.