Imidization during polymerization of acrylamide