Fabrication of rigid polyimide foams with good mechanical and thermal properties