Improve and extend filepos-to-bufferpos