Greetings!
The main reason that I purchased my Pentax K~x is that it would use older K mount and M42 mount lenses. I have quite a few of them. One of them had a rear flange that would not allow the lens to fit onto my camera. Lucky for me, I found this website that told me how to do it. It was a simple fix and the lens now fits on my K-x and works fine.
I was really glad to see other threads that had mentioned the same problem, and pointed me in the right direction.
I used my dremel tool to remove the excess material on the flange. Instead of grinding the flange, I cut off the excess material with a diamond saw blade. The job went very quickly and I was able to keep a straight line while cutting.