There are 3 ways for upVec to be found:
2 and 3 versions were suggested by mano-wii from here http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve
Cross vec. https://github.com/mifth/mifthtools/blob/d967dafaefc3793d0dba0e081ac8c5177d8c0d59/blender/addons/mira_tools/mi_curve_guide.py#L484-L495https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L486-L488
Project vec. http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&p=2866256&viewfull=1#post2866256 https://github.com/mifth/mifthtools/blob/d967dafaefc3793d0dba0e081ac8c5177d8c0d59/blender/addons/mira_tools/mi_curve_guide.py#L497-L499https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L490-L492
Dot vec. http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&p=2866427&viewfull=1#post2866427 https://github.com/mifth/mifthtools/blob/d967dafaefc3793d0dba0e081ac8c5177d8c0d59/blender/addons/mira_tools/mi_curve_guide.py#L501-L504https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L494-L497
I found that Dotchoosed Cross vec for my approach makes less artifacts for the upVec searching. You can comment/uncomment any of approaches to testand try testing.
Also,I found another issue: One direction can has different upVecs. https://i.sstatic.net/WBhG3.png
To fix this issue I have to pick first point upVec and then check all points after. If a current upVecAngle is more than 90 degrees - we need to invert upVec. Here is the code to fix this issue: https://github.com/mifth/mifthtools/blob/d967dafaefc3793d0dba0e081ac8c5177d8c0d59/blender/addons/mira_tools/mi_curve_guide.py#L510-L516https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L504-L509
And you can see the result of my custom curve in editmode here: https://www.youtube.com/watch?v=VXWSUwOul-s