Thanks very much for your filter. I was able to use it in my printer's own driver (in this case, the Lexmark X543), by adding the following line to my printer's PPD:
*cupsPreFilter: "application/pdf 0 pdftograyscalepdf"
This should work in CUPS 1.3 and later (i.e. any version one's likely to come across these days).
This technique makes it easy to copy-and-modify a driver to get a grayscale version, without giving up printer-specific options (as one does if one uses the generic PDF driver).