Whenever any action, claim or proceeding is instituted against any director, officer, employee or agent of a school district or educational service district arising out of the performance or failure of performance of duties for, or employment with any such district, the board of directors of the school district or educational service district board, as the case may be, may grant a request by such person that the prosecuting attorney and/or attorney of the district's choosing be authorized to defend said claim, suit or proceeding, and the costs of defense, attorney's fees, and any obligation for payment arising from such action may be paid from the school district's general fund, or in the case of an educational service district, from any appropriation made for the support of the educational service district, to which said person is attached: PROVIDED, That costs of defense and/or judgment against such person shall not be paid in any case where the court has found that such person was not acting in good faith or within the scope of his or her employment with or duties for the district.