Spectroscopic studies of the diffusion of water and ammonia in polyimide and polyimide-silica hybrids