You only need to do the black ones, as the camera reads the flange itself as white--unless there's any kind of recess like a screw head, which will need to be filled with white paint. I coded all my wide-angle lenses myself by hand-milling recesses for the black codings (note: I have 30 years experience doing things like that). The first one, an adaptor shown below, I milled all 6 but after that, only the black ones as in the other photo. If the code calls for black ones next to each other you can just blacken the entire area, no need for a division ( I discovered that on the last lens I did, the 4th-gen 35 Cron). I found what works great is automotive touch-up paint in those little tubes with the brush in the cap (however I used a toothpick to carry the paint to the recesses).
To line them up, I say forget templates. Take an ULTRA-fine-point Sharpie marker and make a tiny dot on the outside of the M8's lens mount even with the ends of the code reader. Then put the lens on and make marks on its flange lined up with the marks on the body flange. Then remove the lens and draw lines from the marks straight to where the bayonet starts. Make another line bisecting the marked area, and 4 more lines dividing each half into 3. The ULTRA-fine-point Sharpie makes a line the perfect width for the divisions.