after sanding away as much as you can, dampen a cloth with some bleach water, not much at all, and wipe it down, then sand again with a fine grit paper. repeat this process a few times then try painting once it is dry.

Also you can replace the narrow wood pieces, those just hold the glass in the sash. be careful if you remove all four at the same time, the glass might fall out.