Section 8. The county commissioners in each county, except Dukes, shall at the expense of the county provide a house or houses of correction, suitably and efficiently ventilated, with convenient yards, workshops and other suitable accommodations adjoining or appurtenant thereto, for the safe keeping, correction, government and employment of offenders legally committed thereto by the courts and magistrates of the commonwealth or of the United States.