Automatic bag sealer for autoclaves and sterilizers