sp_filt_mkII: merge rtree code into final filter, fix handling of empty objs write

Merge rtree code into the code that finally filters BAMs.  It's fast enough to fit there.
Fix error caused by error checks during object serialisation.