Fixed error handling for serving files