Python: Up-Vector math for Curve
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

1) Cross vec. https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L486-L488

2) Project vec.
http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&amp;p=2866256&amp;viewfull=1#post2866256
https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L490-L492

3) Dot vec.
http://blenderartists.org/forum/showthread.php?361154-Coordinates-of-resolution-points-of-a-Bezier-Curve&amp;p=2866427&amp;viewfull=1#post2866427
https://github.com/mifth/mifthtools/blob/6b0469faea18d3375c3f3257963d7c85f327c44c/blender/addons/mira_tools/mi_curve_guide.py#L494-L497

I choosed Cross vec for my approach for the upVec searching.
You can comment/uncomment any of approaches and try testing.

Also,I found another issue:
One direction can has different upVecs.
http://i.imgur.com/itANWG6.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/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