Changing the attitude reference over time is not that difficult provided the angles moved are small. The Quaternion math section shows how to put moved angles into the representation.
Simply stated: The angles are the rotation rates, as measured by the gyros, multiplied by the time interval.
You can store the instantaneous rates as well, if there is a need.
The interesting part comes when it is time to correct the assorted errors. Thinks like drift, random noise, and limited precision storage and math. The good news is that while you might be measuring the gyros and integrating the attitude representation 200 times a second, the ability to update this representation with a measurment from another source will be much less often.
This is where (kalman) filtering comes in. Your gyro based IMU has been merrily running along, blindly collecting errors for a while, then you get an update from, say a star sensor. Integrating the star sensor measurements, which has different error characteristics and may update at erratic intervals, with the gyro sensor measurements, is done by folding in the new measurements and compensating for the different kind of errors.