Convert Cycles depth/z to distance to image plane
I got it with a slightly different formula. Given the field of view (fov) as 

bpy.context.object.data.lens_unit = 'FOV'
fov = bpy.context.object.data.angle


and the intrinsic components of the camera as

f = (im_width / 2) / tan(fov / 2)
px = im_width / 2
py = im_height / 2


I can transform the depth as follows

zc[v,u] = zs[v,u] * f / sqrt(f**2 + (px - u - 0.5)**2 + (py - v - 0.5)**2)