For you calibration values. magZmax doesnt look correct.
#define magXmax 463
#define magYmax 702
#define magZmax -868
#define magXmin 409
#define magYmin 654
#define magZmin -963
I have never seen this value in a negative. It does definitely go above 0. Below is a random line from your output and the value is 10
heading 289.427 magRaw X 458 magRaw Y 520 MagRaw Z 10
Try manually changing it to 850 and see if it makes a difference.
When you do the calibration, are you rotating the IMU in all directions for about 30 seconds?
Mark --OzzMaker.com --