Section 13. Except as provided in section twenty-eight of chapter two hundred and eighteen and in section twenty of chapter two hundred and nineteen, whoever is convicted of a misdemeanor may, in addition to the punishment prescribed by law, be required to recognize, with sufficient sureties, in a reasonable sum to keep the peace, or to be of good behavior, or both, for any term of not more than two years, and to stand committed until he so recognizes.