Extend CDB_BuildPyramid to accept an explicit max resolution

When not given the function still attempts to find a good value itself.