§ 307. Liens. Every fine imposed by judgment under section three hundred four upon an owner shall be a lien upon the premises in relation to which the fine is imposed from the time of the filing of a certified copy of said judgment in the office of the clerk of the county in which such premises are situated, subject only to taxes, assessments and water rates and to such mortgage and mechanics' liens as may exist thereon prior to such filing; and it shall be the duty of the department upon the entry of said judgment to file such certified copy forthwith, and such copy shall be forthwith indexed by such clerk in the index of mechanics' liens.