Fix imread install and move libm removal to after optional pkg install.