Is it a good idea to write to some researchers for some help on my own research? I am a Ph.D student and I am currently working on my research project. In this moment I am stuck with it because I suspect there is some error in the algorithm, but I can't recognize it. Unfortunately my supervisor cannot help me at this point. However, I know that in my city there is a good professor who is working on the field, so I was thinking to write to him and ask for a meeting, where I could explain my issue.

Do you think is it a good idea? Would it be better if I ask to my supervisor to intermediate for me? How this kind of email are considered by professors?
I would ask your professor first. Not to arrange a meeting but rather for advice. Maybe he thinks it would be best if you write yourself, maybe he thinks it would be best for him to establish a contact.

Next, remember that professors don't have infinite time, so be properly prepared. You claim that there is an error in the algorithm. So work it out exactly, have multiple examples ready to show that for these examples, the algorithm produces the wrong result, have proofs ready to show what the right result is, etc. You might not need all of it, but it is always better to be able to say "yes, I have it right here" instead of "well, I didn't think of that, maybe I will look at it...". On the other hand, don't send everything in your first email, if the prof thinks he has 20 pages to read to understand your problem, he will most likely not.

All in all, it is not a bad idea. Worst thing that could happen is that the professor has no time for you or doesn't answer your email, then you are at the same point you are right now. So go get some advice from your supervisor on how to best contact him, what to prepare in advance, etc. and write him a message.