If you want to solve the general problem, you can use levenberg-marquardt (LM) optimization.
You want to define a bezier curve with some small number of points. You use LM to optimize the parameters of the curve (the point locations) by minimizing the squared distance to the curve for all of your points. This is your objective function, the sum of squared distances.
The trick is computing the gradient and hessian for LM. You can do this numerically without having to work out any math. Use numerical differentiation to compute the Jacobian (J) which you use to find the gradient. (The Jacobian is also used by LM to approximate the Hessian.)
Matti mentioned GSL for smoothing splines. I didn't know about GSL, but it turns out that it has implementations of LM and numerical differentiation.