I've had some more problems.
On your website the apache rewrite rules are :
RewriteRule ^download/(.*)/.*\.(.*)$ fetch.php?id=$1&type=$2 [L]
Although it seems that when therewrite mode is on the url generates contains the data parameter and not the id parameter.
When changing the rule to RewriteRule ^download/(.*)/.*\.(.*)$ fetch.php?data=$1&type=$2 [L]
it works fine.
I also changed last line of fetch.php to
readfile($config['calibre_internal_directory'] . $file);
as I could not use X_send_File.
It's probably slower but works on my server.
Now it's all working well.