The CIAnnotation application shows compositing, painting, Appkit/CG rendering into a CIImage as well as exporting a CIImage and printing. It includes 2 custom Image Units that demonstrate how to write your own CIFilter.