Instead of beziers, you probably want b-splines or catmull-rom splines.
Usage: t ranges from 0 to 1, where the value interpolates the spline between two control points, and the floats p0, p1, p2 and p3 are represent the control points (previous, current, next, and the following). To interpolate n-dimensional curves, just call the functions once per axis.
The practical difference between bsplines and catmull-rom is basically that catmull-rom goes through all control points while bsplines are more smooth.
I found a couple of links that might be useful for others:
Example script of Bezier implementation in JS
Online drawing script/plot, quite useful if you want to make some tests
A bit of theory and an implementation example