Section 65K. Any person aggrieved by a decision of a local board of health or of the department in refusing to grant or to reinstate, or in revoking or suspending, a license or permit, as the case may be, may, within fifteen days after the entry of such decision, bring a petition in the supreme judicial court for a writ of certiorari to correct errors of law therein, and the provisions of section four of chapter two hundred and forty-nine shall, except as herein provided, apply to said petition. No costs shall be allowed against the local board of health or the department, as the case may be, unless the court finds that it acted with gross negligence or in bad faith.