Improved GetLatestImages(id, n) function. On id=0 the function returns the latest n pics ordered by timestamp, otherwise from id to id-n